<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>07 v-on</title>
</head>
<body>
  <div id="app">
    <div>{{ num }}</div>
    <button v-on:click="num++">加1</button>
    <button v-on:click="addFn1">加10</button>
    <button @click="addFn2(100)">加参数100</button>
    <hr />
    <input type="text" v-model="tel" @keyup="getTel" /><hr />
    <input type="text" v-model="tel1" @keyup="getTel1('18813009814', $event)" /><hr />
    <h3>体验vue的修饰符</h3>
    <input type="text" v-model="tel2" @keyup.a="getTel2" ><br />
    <input type="text" @keyup.shift.c="getData">

  </div>
</body>
<script src="lib/vue.js"></script>
<script>
  new Vue({
    el: '#app',
    data: {
      num: 100,
      tel: '',
      tel1: '1',
      tel2: '12'
    },
    methods: { // 表示自定义事件的地方
      addFn1 () {
        this.num += 10
      },
      addFn2 (val) {
        this.num += val
      },
      getTel (event) { // 定义事件没有（）代表有默认参数为event
        if (event.keyCode === 13) {
          console.log(this.tel)
        }
      },
      getTel1 (val, event) { // 定义事件添加().如果要用事件对象，添加$event参数
        if (event.keyCode === 13) {
          console.log(this.tel1)
        }
      },
      getTel2 () {
        console.log(this.tel2)
      },
      getData () {
        console.log('11111')
      }
    }
  })
</script>
</html>
